﻿#函数式编程 将函数作为参数
# def compu(a ,b ,func):
	# return func(a,b);

# def add(a,b):
	# return a+b;

# print(compu(2,3,add));

#map reduce 
#map是对于列表中每个元素进行的映射
# def f(x):
	# return x*x;
# r = map(f,[1,2,3,4,5]);
# print(list(r));

# #reduce 就是将结果和其他数各进行函数操作
# from functools import reduce
# def add(x,y):
	# return x+y;
# num = reduce(add,[1,2,3,4,6,7]);
# print(num);

# #filter 筛选
# def is_odd(n):
	# if n%2==0:
		# return False;
	# else:
		# return True;
# L = list(filter(is_odd,[1,2,3,5,6]))
# print(L);

# #lambda表达式 匿名函数
# f = lambda x:x*x;
# Tx = f(4);
# print(Tx);

# 装饰器 pass
def hello(func):
	func();
	print("hello");
	# return hello;

# @hello
def now():
	print("nuw");
# now();
hello(now);

#作用域
# _abc，__abc是私有变量或者函数 不能被外部访问

#第三方模块
# from PIL import Image
# im = Image.open("test.png");
# print(im.format,im.size,im.mode);